part of '../repository.dart';

const _kUserIdKey = 'id';
const _kUserEmailKey = 'email';

class _UserDto extends Equatable {
  const _UserDto._internal({
    required this.id,
    required this.email,
  });

  final String id;
  final String email;

  @override
  List<Object?> get props {
    return [
      id,
      email,
    ];
  }

  factory _UserDto.fromJson(Map<String, dynamic> json) {
    return _UserDto._internal(
      id: json[_kUserIdKey],
      email: json[_kUserEmailKey],
    );
  }

  factory _UserDto.fromEntity(User user) {
    return _UserDto._internal(
      id: user.id,
      email: user.email,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      _kUserIdKey: id,
      _kUserEmailKey: email,
    };
  }

  User toEntity() {
    return User(
      id: id,
      email: email,
    );
  }
}
